(function() {
  var Config, Logger, MongoConfig, Mongoose, getMongooseConnection, mongooseConOptions;

  Mongoose = require('mongoose');

  Config = require('../config');

  MongoConfig = Config.mongo;

  Logger = require('log4js').getLogger();

  mongooseConOptions = {
    server: {
      poolSize: MongoConfig.poolSize
    }
  };

  getMongooseConnection = function(options) {
    var conn, mongooseConnectStr;
    mongooseConnectStr = "mongodb://" + options.user + ":" + options.pwd + "@" + MongoConfig.host + ":" + MongoConfig.port + "/" + options.db;
    Logger.info("mongooseConnectStr:" + mongooseConnectStr);
    conn = Mongoose.createConnection(mongooseConnectStr, mongooseConOptions, function(err) {
      if (err) {
        return Logger.error("mongoose error:" + err);
      }
    });
    return conn;
  };

  module.exports = {
    getMongooseConnection: getMongooseConnection
  };

}).call(this);
